<?php
/*添加数据*/
	error_reporting(0);
	$left = trim($_POST['left']);
	$right = trim($_POST['right']);

	$token = trim($_POST['token']);
	$tid = trim($_POST['tid']);
	$tName = trim($_POST['tName']);
	if(!$tid || !$tName || $tid == 'all'){
		exit('tabType is error');
	}
	if(!$left || !$right){
		exit('输入格式为：a--->aaa');
	}
	require '../autoload.php';

	//token 验证
	if(!token_v('infoAdd',$token)){
		exit('token is error !');
	}
	$mp = new MyPdo();
	$sql = "select id from translate_info where typeid = ? and lefts = ?";
	$arr = array($tid,$left);
	$res = $mp->dql($sql,$arr,1);
	if($res){
		exit('数据已存在！');
	}else{
		$sql = "insert into translate_info values(null,?,?,?)";
		$arr = array($left,$right,$tid);
		$res = $mp->dml($sql,$arr);
		if($res){
			echo '添加成功！';		
			$sql = 'select id from translate_not_join where tid = ?';
			$res = $mp->dql($sql,array($tid));
			if(!$res){
				$fileName[] = '../Runtime/Cache_long/all';
				//$fileName[] = '../Runtime/CacheLefts/'.md5('all');
			}
			$fileName[] = '../Runtime/Cache_long/'.$tName;
			//$fileName[] = '../Runtime/CacheLefts/'.md5($tid);
			$fileName[] = '../Runtime/CacheInfoAll/'.$tName;
			$fileName[] = '../Runtime/CacheLeftVague/'.$tName;
			$fileName[] = '../Runtime/CacheRightVague/'.$tName;
			foreach($fileName as $v){
				rmdirs($v);	
			}
		}else{
			echo 'insert is error';
		}
	}



	/*
		Cache_long
			cc

		CacheInfoAll
			cc

		CacehLefts
			3个都留

		CacheLeftVague
			cc
				2文件

		CacheRight
			xx
				2文件
			cc
				2文件
		CacheRightVague
			cc
				2文件



	*/